import {pageOptions} from '@/views/custom/mobiledesign/components/mobileConfig.js';
let pageStore = [];
pageOptions.forEach(item=>{
  if(item.children && Array.isArray(item.children)){
    item.children.forEach(val=>{
      pageStore.push(val.name);
    })
  }
});
let deviceCode = (function(){
  let userAgent = navigator.userAgent.toLowerCase();
    if (/ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/.test(userAgent)) {
        console.log('当前是移动端')
        return 'mobile';
    } else {
        console.log('当前是pc端')
        return 'pc';
    }
})();
const state = {
userAgent:deviceCode,
isClick:false,
isJump:false,
pageStore,
functionMenu:[]
}
const mutations = {
SET_AGENT:(state,val) => {
  state.userAgent = val;
},
SET_CLICK:(state,val) => {
  state.isClick = val;
},
SET_JUMP:(state,val) => {
  state.isJump = val;
},
SET_PAGESTORE:(state,val) => {
  let arr = [];
  val.forEach(item=>{
  if(item.children && Array.isArray(item.children)){
    item.children.forEach(cur=>{
      arr.push(cur.name);
    })
  }
});
  state.pageStore = arr;
},
SET_FUNCTIONMENU:(state,val) => {
  let arr = val.map(item=>{
    return {
      name:item.name,
      path:item.path
    }
  })
  state.functionMenu = arr;
}
}
export default {
namespaced: true,
  state,
  mutations
}